<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MyGroup extends CI_Controller{
    function __construct(){
        parent::__construct();
    }

    public function index() {

        redirect('home');
    }
    public function showMyGroupData()
    {
        if(!$this->session->userdata('validated'))
        {
            redirect('home');
        }

        $this->load->helper('url');

        $this->load->view('templates/header');
        $this->load->view('templates/navigation_logged');
        $this->load->view('pages/mygroup');
        $this->load->view('templates/footer');
    }
    public function leaveGroup()
    {
        $username = $this->session->userdata('username');
        $data = array(
            'group' => ""
        );

        $this->db->where('username', $username);
        $this->db->update('users', $data);
        $this->session->set_userdata(array('group' => ""));
        $this->session->set_flashdata('left', 'Αποχωρήσατε επιτυχώς από την ομάδα!');
        redirect('mygroup');
    }
}
?>